//微信统计系统开发——小悟空 v1.0.6 🐧：894251491
function guid() {
    var d = new Date().getTime();
    if (window.performance && typeof window.performance.now === "function") {
        d += performance.now()
    }
    var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
    function(c) {
        var r = (d + Math.random() * 16) % 16 | 0;
        d = Math.floor(d / 16);
        return (c == 'x' ? r: (r & 0x3 | 0x8)).toString(16)
    });
    return uuid
};
window.onload = function() {
    setInterval("t_time()", 1000);
    ScollPostion();
    if (getCookie('lockme') == null) { 
        setCookie('lockme', 0)
    } else {
        setCookie('lockme', parseInt(getCookie('lockme')) + 1)
    }
};
function t_time() {
    ScollPostion();
    time_dw += 1;
    if (time_dw == 1) {
        if (dw_ref == '' && parseInt(getCookie('lockme')) >= 2) {
            return false
        } else {
            look(0)
        }
        r_time = 1 * 2 + Math.floor(Math.random() * 3);
		
    };
    if (time_dw == r_time) {
        if (dw_ref == '' && parseInt(getCookie('lockme')) >= 2) {
            return false
        } else {
            look(1)
        }
        r_time = Math.round(r_time * 1.5) + Math.floor(Math.random() * 6)
    }
	// console.log(time_dw,r_time);
	console.table(ym_height,ym_lock);
};
function ScollPostion() {
    var t, h;
    if (document.documentElement && document.documentElement.scrollTop) {
        t = document.documentElement.scrollTop;
        h = document.documentElement.scrollHeight
    } else if (document.body) {
        t = document.body.scrollTop;
        h = document.body.scrollHeight
    }
	
    r_height = t + document.documentElement.clientHeight;
    
    if (r_height > ym_lock) {
        ym_lock = r_height
    }
    ym_height = h
	
};
function look(e) {
    dw_gurl = "http://"+domain+"/api/index/everyTime?ali_uId=" + dw_uId + "&ali_url=" + escape(dw_url) + "&ali_ref=" + escape(dw_ref) + "&ali_v=" + unique() + "&ali_utid=" + utid + "&page_height=" + ym_height + "&read_time=" + time_dw + "&v_type=" + e + '&page_lock=' + ym_lock + ' &show_wx=' + stxlwx;
    setTimeout('dw_img = new Image;dw_img.src=dw_gurl;', 1)
};


try {
    js_url = document.getElementById("dwtongji").src
} catch(e) {}
try {
    dw_uId = getURLParam("dw", js_url)
} catch(e) {}
try {
    dw_gId = getURLParam("gid", js_url)
} catch(e) {}
try {
    dw_url = window.parent.location
} catch(e) {}
try {
    dw_ref = window.parent.document.referrer
} catch(e) {}
setInterval(function() {
    var str = encodeURIComponent(window.getSelection(0).toString());
    if (str != "" && copy_content != str) {
        copy_content = str;
        copy_type = 1;
        setTimeout(tj(), 1)
    }
},
1800);
// 监听页面复制动作
document.addEventListener('copy',
function(event) {
    try {
        var str = encodeURIComponent(window.getSelection(0).toString());
        if (str != "" && copy_content != str) {
            copy_content = str;
            copy_type = 2;
            setTimeout(tj(), 1)
        }
    } catch(e) {}
});
function tj() {
    if (myArray.indexOf(copy_content) == -1) {
        dw_gurl = "http://"+domain+"/api/index/addCopy?ali_uId=" + dw_uId + "&copy_type=" + copy_type + "&ali_url=" + escape(dw_url) + "&ali_ref=" + escape(dw_ref) + "&ali_c=" + copy_content +"&show_wx="+stxlwx +"&ali_v=" + unique() + "&read_time=" + time_dw + "&ali_utid=" + utid + '&page_lock=' + ym_lock + "&page_height=" + ym_height;
        setTimeout("dw_img = new Image;dw_img.src=dw_gurl;", 1)
    }
    myArray[myArray.length] = copy_content
}
function customize(auname) {
    dw_gurl = "http://"+domain+"/api/index/addCopy?ali_uId=" + dw_uId + "&copy_type=" + 3 + "&ali_url=" + escape(dw_url) + "&ali_ref=" + escape(dw_ref) + "&ali_c=zdy&zdy=" + auname + "&ali_v=" + unique() + "&read_time=" + time_dw + "&ali_utid=" + utid + '&page_lock=' + ym_lock + "&page_height=" + ym_height;
    setTimeout("dw_img = new Image;dw_img.src=dw_gurl;", 1)
}
function getURLParam(strParamName, url) {
    var strReturn = "";
    var strHref = url.toLowerCase();
    if (strHref.indexOf("?") > -1) {
        var strQueryString = strHref.substr(strHref.indexOf("?") + 1).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for (var iParam = 0; iParam < aQueryString.length; iParam++) {
            if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1) {
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break
            }
        }
    }
    return strReturn
}
function unique() {
    var time = (new Date()).getTime() + "-",
    i = 0;
    return time + (i++)
};
function setCookie(name, value) {
    var exp = new Date();
    exp.setTime(exp.getTime() + 3 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString()
}
function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg)) {
        return unescape(arr[2])
    } else {
        return null
    }
};



